package com.ihrm.company.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author chahua
 * @date 2022/3/26 16:34
 **/
@Configuration
@EnableSwagger2
public class Swagger2Configuration {
    //com.ihrm.company包下面的所有加了@Controller注解类中的的接口方法都可以扫描到
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ihrm.company"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Sass多租户啊hrm管理系统")
                .description("Sass多租户hrm管理系统api文档")
                .version("1.0")
                .build();
    }
}
